Skip to content

Conversation

@tschwarzl
Copy link

addressing issue #502

added type checks for new_object() argument .parent asserting that it is of type S7 object not S7_class

…nforcing S7_object and prohibiting S7_class passing.
@tschwarzl tschwarzl changed the title #502 added type checks for new_object() argument .parent added type checks for new_object() argument .parent Nov 22, 2024
Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. This will be a nice improvement in user friendliness.


#' @param .parent,... Parent object and named properties used to construct the
#' object.
#' @param .parent,... Parent S7 object and named properties used to construct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessarily an S7 object, because the class might extend a base class.

if (!inherits(.parent, "S7_object"))
stop("`.parent` needs to be an S7_object")
if (inherits(.parent, "S7_class")) {
stop(paste("`.parent` cannot be of type S7_class. Did you type",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please put this on two lines and add a snapshot test for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants